import React, {Component} from 'react';
import styled from '../styled.less';
import {getQueryString} from '@/utils/util';
import {getDeviceWisdomElectricityDetail} from '../service';

export default class ElectricityDetailHeaderLeft extends Component {

  state = {
    id: getQueryString('id'),
    electricityDetail: {}
  };

  componentWillMount() {
    getDeviceWisdomElectricityDetail(this.state.id).then(data => {
      this.setState({
        electricityDetail: data
      })
    });
  }

  render () {
    const {electricityDetail = {}} = this.state;
    return (
      <div className="head-left">
        <ul className={styled.detail_head_left}>
          <li>设备名称：{electricityDetail['name'] ? electricityDetail['name'] : '-'}</li>
          <li>安装地址：{electricityDetail['installLocationName'] ? `${electricityDetail['installLocationName']}` : '-'}</li>
          <li>安装时间：{electricityDetail['createTime'] ? electricityDetail['createTime'] : '-'}</li>
          <li>型号：{electricityDetail['productName'] ? electricityDetail['productName'] : '-'}</li>
          <li>联网方式：{electricityDetail['wisdomElectricityOnlineTypeName'] ? electricityDetail['wisdomElectricityOnlineTypeName'] : '-'}</li>
          <li>厂家：{electricityDetail['brandName'] ? electricityDetail['brandName'] : '-'}</li>
          <li>设备ID：{electricityDetail['networkAddr'] ? electricityDetail['networkAddr'] : '-'}</li>
          <li>温度1/℃：{electricityDetail['valueMap'] ? electricityDetail['valueMap']['temperature1'] ? electricityDetail['valueMap']['temperature1'] : '-' : '-'}</li>
          <li>电压值/V：{electricityDetail['valueMap'] ? electricityDetail['valueMap']['voltage'] ? electricityDetail['valueMap']['voltage'] : '-' : '-'}</li>
          <li>温度2/℃：{electricityDetail['valueMap'] ? electricityDetail['valueMap']['temperature2'] ? electricityDetail['valueMap']['temperature2'] : '-' : '-'}</li>
          <li>运行状态：{electricityDetail['runStatusName'] ? electricityDetail['runStatusName'] : '-'}</li>
          <li>温度3/℃：{electricityDetail['valueMap'] ? electricityDetail['valueMap']['temperature3'] ? electricityDetail['valueMap']['temperature3'] : '-' : '-'}</li>
          <li>电流值/A：{electricityDetail['valueMap'] ? electricityDetail['valueMap']['ampere'] ? electricityDetail['valueMap']['ampere'] : '-' : '-'}</li>
          <li>温度4/℃：{electricityDetail['valueMap'] ? electricityDetail['valueMap']['temperature4'] ? electricityDetail['valueMap']['temperature4'] : '-' : '-'}</li>
          <li>剩余电流值：{electricityDetail['valueMap'] ? electricityDetail['valueMap']['leakage'] ? electricityDetail['valueMap']['leakage'] : '-' : '-'}</li>
        </ul>
      </div>
    )
  }
}
